package com.jumi.microservice.rocketmq;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.order.ConsumeOrderContext;
import com.aliyun.openservices.ons.api.order.MessageOrderListener;
import com.aliyun.openservices.ons.api.order.OrderAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class RocketMessageListener implements MessageOrderListener {

    private static final Logger log = LoggerFactory.getLogger(RocketMessageListener.class);
    @Override
    public OrderAction consume(Message message, ConsumeOrderContext context) {
        log.info("消息推送" + message);
        try {
            //do something..
            return OrderAction.Success;
        } catch (Exception e) {
            //消费失败，挂起当前队列
            return OrderAction.Suspend;
        }
    }
}
